# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=adns
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
_tag=adns-1.4-g10-7
pkgver=${_tag//adns-/}
pkgver=${pkgver//-/.}
pkgrel=1
pkgdesc="adns is an asyncronous replacement resolver library (mingw-w64)"
arch=('any')
url="https://www.chiark.greenend.org.uk/~ian/adns/"
license=('GPL LGPL')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-pkg-config"
             "git")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
source=(git+https://dev.gnupg.org/source/adns.git#commit=c363fb22d3ce24552ab97572e348d2b024a9f16a
        mingw-no-regress.patch
        mingw-mkdir.patch)
sha256sums=('SKIP'
            '56309cdcd39899124aa62f1231a3444886d4b460d520e390308c084749208249'
            'cd0384622dee28f9f034df0d2e67fc7e0e2b2aab636405b862df86baab1279e3')

prepare() {
  cd ${_realname}
  patch -p1 -i ${srcdir}/mingw-no-regress.patch
  patch -p1 -i ${srcdir}/mingw-mkdir.patch
  ./autogen.sh
}
build() {
  [[ -d build-${MINGW_CHOST} ]] && rm -rf build-${MINGW_CHOST}
  mkdir -p build-${MINGW_CHOST}
  cd build-${MINGW_CHOST}

  ../${_realname}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-static \
    --enable-shared

  make
}

package() {
  cd "build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install

  install -Dm0755 ${srcdir}/${_realname}/LICENCE.WAIVERS "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}/LICENCE.WAIVERS
}
